#include<stdio.h>
FILE *Finp=fopen("PUZZLE.INP","r");
FILE *Fout=fopen("PUZZLE.OUT","w");
char board[21][21];
char string[21][21];
char len[21]={0};
char mark[21][21];
int flag=0;
int rows,collums,k;
void input(){
    int i,j;
    for(i=0;i<21;i++)
        for(j=0;j<21;j++)
            len[i]=board[i][j]=string[i][j]=mark[i][j]=0;
    fscanf(Finp,"%d%d%d",&rows,&collums,&k);
    for(i=0;i<k;i++){
        fscanf(Finp,"%s",string[i]);
        for(j=0;string[i][j]!=0;j++);
        len[i]=j;
    }
    for(i=0;i<rows;i++)fscanf(Finp,"%s",board[i]);
}
void ngang(int row,int collum,int index){
    int i;
    if(collums-collum<len[index])return;
    for(i=0;i<len[index];i++)if(string[index][i]!=board[row][collum+i])return;
    for(i=0;i<len[index];i++)mark[row][collum+i]=1;
}
void doc(int row,int collum,int index){
    int i;
    if(rows-row<len[index])return;
    for(i=0;i<len[index];i++)if(string[index][i]!=board[row+i][collum])return;
    for(i=0;i<len[index];i++)mark[row+i][collum]=1;
}
void solve(){
    int row,collum,index;
    for(row=0;row<rows;row++)
        for(collum=0;collum<collums;collum++)
            for(index=0;index<k;index++){
                ngang(row,collum,index);
                doc(row,collum,index);
            }   
}
void writeOutput(){
    int i,j;
    if(flag==0)flag=1;
    else fprintf(Fout,"\n");
    for(i=0;i<rows;i++)
        for(j=0;j<collums;j++)
            if(mark[i][j]==0)fprintf(Fout,"%c",board[i][j]);
}
int main(){
    int tests,i;
    fscanf(Finp,"%d",&tests);
    for(i=1;i<=tests;i++){
        input();
        solve();
        writeOutput();
    }
    fclose(Finp);
    fclose(Fout);
    return 0;
}
    
